﻿using Service.Framework.Utils.Helper;
using Service.Repository;
using SqlSugar;
namespace Service.Core.Repository.Core
{

    /// <summary>
    /// 短信日志表
    /// </summary>

    [SugarIndex("phone_inx", nameof(PhoneNumber), OrderByType.Desc)]
    [SplitTable(SplitType.Year)]
    [SugarTable("tb_sms_record_log_{year}{month}{day}")]
    [Tenant(DbTenantEnum.Log)]
    public class SmsRecordLog : Entity, IAggregateRoot
    {
        public SmsRecordLog()
        {
        }

        public SmsRecordLog(string supplierName, string templateName, string templateParam, string signName, string phoneNumber, bool success, string msg)
        {
            Id = SnowflakeUtil.Instance().GetId();
            SupplierName = supplierName;
            TemplateName = templateName;
            TemplateParam = templateParam;
            SignName = signName;
            PhoneNumber = phoneNumber;
            Msg = msg;
            Success = success;
            CreateTime = DateTime.Now;
        }

        [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
        public long Id { get; private set; }


        /// <summary>
        /// 短信供应商
        /// </summary>
        [SugarColumn(ColumnName = "supplier_name")]
        public string SupplierName { get; private set; }

        /// <summary>
        /// 模板名称
        /// </summary>
        [SugarColumn(ColumnName = "template_name", IsNullable = true)]
        public string TemplateName { get; private set; }

        /// <summary>
        /// 模板参数
        /// </summary>
        [SugarColumn(ColumnName = "template_param", IsNullable = true)]
        public string TemplateParam { get; private set; }


        /// <summary>
        /// 签名名称
        /// </summary>
        [SugarColumn(ColumnName = "sign_name", IsNullable = true)]
        public string SignName { get; private set; }


        /// <summary>
        /// 手机号码
        /// </summary>
        [SugarColumn(ColumnName = "phone_number")]
        public string PhoneNumber { get; private set; }


        /// <summary>
        /// 消息，失败原因
        /// </summary>
        [SugarColumn(ColumnName = "msg", IsNullable = true)]
        public string Msg { get; private set; }


        /// <summary>
        /// 是否成功
        /// </summary>
        [SugarColumn(ColumnName = "success")]
        public Boolean Success { get; private set; }


        /// <summary>
        /// 创建时间
        /// </summary>
        [SplitField]
        [SugarColumn(ColumnName = "create_time")]
        public DateTime CreateTime { get; private set; }
    }
}
